package com.cq.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.cq.system.domain.SxNft;
import com.cq.system.service.ISxNftService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 版权Controller
 * 
 * @author cq
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/nft")
public class SxNftController extends BaseController
{
    @Autowired
    private ISxNftService sxNftService;

    /**
     * 查询版权列表
     */
    @PreAuthorize("@ss.hasPermi('system:nft:list')")
    @GetMapping("/list")
    public TableDataInfo list(SxNft sxNft)
    {
        startPage();
        List<SxNft> list = sxNftService.selectSxNftList(sxNft);
        return getDataTable(list);
    }

    /**
     * 导出版权列表
     */
    @PreAuthorize("@ss.hasPermi('system:nft:export')")
    @Log(title = "版权", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SxNft sxNft)
    {
        List<SxNft> list = sxNftService.selectSxNftList(sxNft);
        ExcelUtil<SxNft> util = new ExcelUtil<SxNft>(SxNft.class);
        util.exportExcel(response, list, "版权数据");
    }

    /**
     * 获取版权详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:nft:query')")
    @GetMapping(value = "/{nftId}")
    public AjaxResult getInfo(@PathVariable("nftId") Long nftId)
    {
        return success(sxNftService.selectSxNftByNftId(nftId));
    }

    /**
     * 新增版权
     */
    @PreAuthorize("@ss.hasPermi('system:nft:add')")
    @Log(title = "版权", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SxNft sxNft)
    {
        return toAjax(sxNftService.insertSxNft(sxNft));
    }

    /**
     * 修改版权
     */
    @PreAuthorize("@ss.hasPermi('system:nft:edit')")
    @Log(title = "版权", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SxNft sxNft)
    {
        return toAjax(sxNftService.updateSxNft(sxNft));
    }

    /**
     * 删除版权
     */
    @PreAuthorize("@ss.hasPermi('system:nft:remove')")
    @Log(title = "版权", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nftIds}")
    public AjaxResult remove(@PathVariable Long[] nftIds)
    {
        return toAjax(sxNftService.deleteSxNftByNftIds(nftIds));
    }
}
